<template>
  <view class="merchant-header">
    <!-- 背景图 -->
    <image :src="merchantInfo.coverImage" class="cover-image" mode="aspectFill"></image>
    
    <!-- 商家信息卡片 -->
    <view class="merchant-card">
      <view class="card-top">
        <image :src="merchantInfo.logo" class="merchant-logo"></image>
        <view class="merchant-main">
          <view class="merchant-name-row">
            <text class="merchant-name">{{ merchantInfo.name }}</text>
          </view>
          <view class="merchant-tags">
            <view v-for="tag in merchantInfo.tags" :key="tag" class="tag">
              {{ tag }}
            </view>
          </view>
        </view>
      </view>
      
      <view class="card-stats">
        <view class="stat-item">
          <uni-icons type="star-filled" size="16" color="#FFD700"></uni-icons>
          <text class="stat-text">{{ merchantInfo.rating }}</text>
        </view>
        <view class="stat-divider">|</view>
        <view class="stat-item">
          <text class="stat-text">月售{{ merchantInfo.sales }}</text>
        </view>
        <view class="stat-divider">|</view>
        <view class="stat-item">
          <text class="stat-text">{{ merchantInfo.distance }}km</text>
        </view>
      </view>
      
      <view class="card-delivery">
        <text class="delivery-info">¥{{ merchantInfo.minPrice }}起送 | 配送费¥{{ merchantInfo.deliveryFee }}</text>
      </view>
    </view>

    <!-- 公告栏 -->
    <view v-if="merchantInfo.notice" class="notice-bar">
      <uni-icons type="sound" size="18" color="#00C853"></uni-icons>
      <text class="notice-text">{{ merchantInfo.notice }}</text>
    </view>
  </view>
</template>

<script setup lang="ts">
interface MerchantInfo {
  id: number;
  name: string;
  logo: string;
  coverImage: string;
  rating: number;
  sales: number;
  distance: number;
  minPrice: number;
  deliveryFee: number;
  tags: string[];
  notice: string;
}

interface Props {
  merchantInfo: MerchantInfo;
}

defineProps<Props>();
</script>

<style scoped>
.merchant-header {
  position: relative;
  background-color: #fff;
}

.cover-image {
  width: 100%;
  height: 300rpx;
}

.merchant-card {
  margin: -60rpx 30rpx 0;
  padding: 30rpx;
  background-color: #fff;
  border-radius: 16rpx;
  box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.08);
}

.card-top {
  display: flex;
  gap: 20rpx;
  margin-bottom: 20rpx;
}

.merchant-logo {
  width: 100rpx;
  height: 100rpx;
  border-radius: 12rpx;
  flex-shrink: 0;
}

.merchant-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10rpx;
}

.merchant-name-row {
  display: flex;
  align-items: center;
}

.merchant-name {
  font-size: 32rpx;
  font-weight: bold;
  color: #333;
}

.merchant-tags {
  display: flex;
  gap: 10rpx;
  flex-wrap: wrap;
}

.tag {
  padding: 4rpx 12rpx;
  background-color: #e6f7ed;
  color: #00C853;
  font-size: 22rpx;
  border-radius: 6rpx;
}

.card-stats {
  display: flex;
  align-items: center;
  gap: 15rpx;
  margin-bottom: 15rpx;
  padding-bottom: 15rpx;
  border-bottom: 1rpx solid #f0f0f0;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 5rpx;
}

.stat-text {
  font-size: 24rpx;
  color: #666;
}

.stat-divider {
  color: #ddd;
  font-size: 24rpx;
}

.card-delivery {
  display: flex;
  align-items: center;
}

.delivery-info {
  font-size: 24rpx;
  color: #999;
}

.notice-bar {
  display: flex;
  align-items: center;
  gap: 10rpx;
  padding: 20rpx 30rpx;
  background-color: #fff9e6;
  margin: 20rpx 30rpx;
  border-radius: 8rpx;
}

.notice-text {
  flex: 1;
  font-size: 24rpx;
  color: #ff9800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</style>